]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Add removeAction() method and allow references to actions
authorPhilip Withnall <pwithnall@gnome.org>
Tue, 28 May 2024 17:03:11 +0000 (18:03 +0100)
committerPhilip Withnall <pwithnall@gnome.org>
Thu, 28 Nov 2024 10:44:02 +0000 (10:44 +0000)
Internally in gnome-shell it may be useful to modify the actions
available on a notification while it’s still visible, but without
clearing them all and re-creating them.

Allow that by returning the action object when adding it, and adding a
`removeAction()` method which takes that object and removes it.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3251>

js/ui/messageTray.js

index 80240b1eedca189c59aeef3431d1e15aa6b75b87..7c6f2f5db2ade239ffea089ac35443a9800fe8f3 100644 (file)
@@ -439,6 +439,16 @@ export class Notification extends GObject.Object {
         });
         this._actions.push(action);
         this.emit('action-added', action);
+        return action;
+    }
+
+    removeAction(action) {
+        const index = this._actions.indexOf(action);
+        if (index < 0)
+            throw new Error('Action was already removed previously');
+
+        this._actions.splice(index, 1);
+        this.emit('action-removed', action);
     }
 
     clearActions() {